package com.longer.demo.framework.error;

/**
 * @program: demo
 * @description:
 * @author: SunBiaoLong
 * @create: 2019-01-11 11:54
 **/
public enum BusinessError implements CommonError {
	//	通用参数类型2000开头
	PARAMETER_VALIDATION_ERROR(20001, "参数不合法"),
	UNKNOWN_ERROR(20001, "未知错误"),

	//	1000开头为用户信息相关的错误定义
	USER_NOT_EXIST(10001, "用户不存在"),
	LOGIN_ERROR(10002, "手机号或密码错误"),
	USER_NOT_LOGIN(10003, "用户尚未登陆"),

	// 3000开头为订单信息相关错误
	STOCK_INSUFFICIENT(30001, "库存不足");

	private BusinessError(int errorCode, String errorMsg) {
		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
	}

	private int errorCode;
	private String errorMsg;

	@Override
	public int getErrorCode() {
		return this.errorCode;
	}

	@Override
	public String getErrorMsg() {
		return this.errorMsg;
	}

	@Override
	public CommonError setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
		return this;
	}
}
